project( portal_adaptation )

# Setup versioning

set( VERSION_MAJOR     0 )
set( VERSION_MINOR     0 )
set( VERSION_REVISION  1 )
set( PROJECT_VERSION
    "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_VERSION}"
)

SET(OGRE_SDK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../common/external/ogre CACHE STRING "Path where OGRE SDK is located")
SET(CEGUI_SDK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../common/external/CEGUI CACHE STRING "Path where CEGUI SDK is located")
SET(AUDIERE_SDK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../common/external/AUDIERE CACHE STRING "Path where AUDIERE SDK is located")
SET(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Od")

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../common)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../common/external)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../common/external/boost)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../common/external/bullet)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../common/external/bullet/src)
# ogre header files
INCLUDE_DIRECTORIES(${OGRE_SDK_PATH}/include)
INCLUDE_DIRECTORIES(${CEGUI_SDK_PATH}/cegui/include)
INCLUDE_DIRECTORIES(${AUDIERE_SDK_PATH}/include)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/view)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/controller)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/model)

# Generate config file
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/../config/resources.cfg.in ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation/resources.cfg)

SET(SRC_CONTROLLER
	src/controller/game.hpp
	src/controller/game.cpp
	src/controller/gamestate/GameState.cpp
	src/controller/gamestate/GameState.hpp
	src/controller/gamestate/GameStateManager.cpp
	src/controller/gamestate/GameStateManager.hpp
	src/controller/main.cpp
	src/controller/PlayState.cpp
	src/controller/PlayState.hpp
	src/controller/Level.cpp
	src/controller/Level.hpp
	src/controller/EventManager.cpp
	src/controller/EventManager.hpp
	src/controller/MenuState.cpp
	src/controller/MenuState.hpp
)

SET(SRC_MODEL
	src/model/dotscene/DotScene.h
	src/model/dotscene/DotScene.cpp
	src/model/Action.hpp
)

SET(SRC_VIEW
	src/view/Character.cpp
	src/view/Character.hpp
	src/view/ObjectTextDisplay.hpp
)

SET(SRC_EXTERNAL
	${CMAKE_CURRENT_SOURCE_DIR}/../common/external/BtOgre/BtOgre.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/../common/external/BtOgre/BtOgreExtras.h
	${CMAKE_CURRENT_SOURCE_DIR}/../common/external/BtOgre/BtOgreGP.h
	${CMAKE_CURRENT_SOURCE_DIR}/../common/external/BtOgre/BtOgrePG.h
	${CMAKE_CURRENT_SOURCE_DIR}/../common/external/tinyxml/tinystr.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/../common/external/tinyxml/tinystr.h
	${CMAKE_CURRENT_SOURCE_DIR}/../common/external/tinyxml/tinyxml.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/../common/external/tinyxml/tinystr.h
	${CMAKE_CURRENT_SOURCE_DIR}/../common/external/tinyxml/tinyxmlerror.cpp
	${CMAKE_CURRENT_SOURCE_DIR}/../common/external/tinyxml/tinyxmlparser.cpp
)

SOURCE_GROUP("Controller" FILES ${SRC_CONTROLLER})
SOURCE_GROUP("View" FILES ${SRC_VIEW})
SOURCE_GROUP("External" FILES ${SRC_EXTERNAL})
SOURCE_GROUP("Model" FILES ${SRC_MODEL})

SET(SOURCES	
	${SRC_CONTROLLER}
	${SRC_VIEW}
	${SRC_MODEL}
	${SRC_EXTERNAL}
)

ADD_EXECUTABLE(PortalAdaptation WIN32
	${SOURCES}
)

SET(OGRE_LIB
	${OGRE_SDK_PATH}/lib/debug/OgreMain_d.lib
	${OGRE_SDK_PATH}/lib/debug/OIS_d.lib
	${OGRE_SDK_PATH}/lib/debug/opt/RenderSystem_Direct3D9_d.lib
)

SET(BULLET_LIB
	${LIBRARY_OUTPUT_PATH}/Debug/BulletSoftBody.lib
	${LIBRARY_OUTPUT_PATH}/Debug/BulletDynamics.lib
	${LIBRARY_OUTPUT_PATH}/Debug/BulletCollision.lib
	${LIBRARY_OUTPUT_PATH}/Debug/LinearMath.lib
)

SET(CEGUI_LIB
	${CEGUI_SDK_PATH}/lib/CEGUIBase_d.lib
	${CEGUI_SDK_PATH}/lib/CEGUIOgreRenderer_d.lib
)

SET(AUDIERE_LIB
	${AUDIERE_SDK_PATH}/lib/audiere.lib
)

TARGET_LINK_LIBRARIES(PortalAdaptation boost ${OGRE_LIB} ${BULLET_LIB} ${CEGUI_LIB} ${AUDIERE_LIB})


add_custom_command(
    TARGET PortalAdaptation
	POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy ${OGRE_SDK_PATH}/bin/debug/OgreMain_d.dll ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	COMMAND ${CMAKE_COMMAND} -E copy ${OGRE_SDK_PATH}/bin/debug/OIS_d.dll ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	COMMAND ${CMAKE_COMMAND} -E copy ${OGRE_SDK_PATH}/bin/debug/RenderSystem_Direct3D9_d.dll ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	COMMAND ${CMAKE_COMMAND} -E copy ${OGRE_SDK_PATH}/bin/debug/Plugin_CgProgramManager_d.dll ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	COMMAND ${CMAKE_COMMAND} -E copy ${OGRE_SDK_PATH}/bin/debug/Plugin_ParticleFX_d.dll ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	COMMAND ${CMAKE_COMMAND} -E copy ${OGRE_SDK_PATH}/bin/debug/cg.dll ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	COMMAND ${CMAKE_COMMAND} -E copy ${CEGUI_SDK_PATH}/bin/CEGUIBase_d.dll ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	COMMAND ${CMAKE_COMMAND} -E copy ${CEGUI_SDK_PATH}/bin/CEGUIOgreRenderer_d.dll ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	COMMAND ${CMAKE_COMMAND} -E copy ${CEGUI_SDK_PATH}/bin/CEGUIExpatParser_d.dll ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	COMMAND ${CMAKE_COMMAND} -E copy ${CEGUI_SDK_PATH}/bin/CEGUIFalagardWRBase_d.dll ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	COMMAND ${CMAKE_COMMAND} -E copy ${AUDIERE_SDK_PATH}/bin/audiere.dll ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	
	COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/data/music/music_level_1.mp3 ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	
	COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../config/plugins.cfg ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
	COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../config/game.cfg ${EXECUTABLE_OUTPUT_PATH}/../portal_adaptation
)

ADD_DEPENDENCIES(PortalAdaptation boost BulletCollision BulletDynamics BulletSoftBody LinearMath)

SET_TARGET_PROPERTIES(
	PortalAdaptation
	PROPERTIES
	FOLDER "Executables"
)
SET_TARGET_PROPERTIES(
	PortalAdaptation
	PROPERTIES
	OUTPUT_NAME "Portal Adaptation"
)

IF(WIN32)

#SET(DEST_DIR ${INSTALL_PATH}/x86)

#IF(CMAKE_CL_64)
#SET(DEST_DIR ${INSTALL_PATH}/x64)
#ELSE(CMAKE_CL_64)
#SET(DEST_DIR ${INSTALL_PATH}/x86)
#ENDIF(CMAKE_CL_64)

#INSTALL(TARGETS PortalAdaptation
#  DESTINATION ${DEST_DIR}
#  CONFIGURATIONS Release RelWithDebInfo
#)

#INSTALL(PortalAdaptation
#	DESTINATION ${DEST_DIR}
#	CONFIGURATIONS Release RelWithDebInfo
#)

ENDIF(WIN32)